package com.ericsson.smart;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class UtilityMetaDataLoader implements UtilityCommonLoader {
	UtilityReportMetaDataLoader reportMetaDataLoader = new UtilityReportMetaDataLoader();
	@Autowired
	UtilityDimnMetaDataLoader dimensionMetaDataLoader;
	//= new UtilityDimnMetaDataLoader();

	public UtilityDimnMetaDataLoader getDimensionMetaDataLoader() {
		return dimensionMetaDataLoader;
	}

	public void setDimensionMetaDataLoader(
			UtilityDimnMetaDataLoader dimensionMetaDataLoader) {
		this.dimensionMetaDataLoader = dimensionMetaDataLoader;
	}

	@Override
	public Map<String, Object> loadingReportMetaData() {
		// System.out.println("inside loadingReportMetaData method of UtilityMetaDataLoader class");
		Map<String, Object> reportMetadata = reportMetaDataLoader.loadReportMetaData();
		System.out.println("REPORT-META-DATA: " + reportMetadata);
		return reportMetadata;
	}

	@Override
	public <T> HashMap<String, ArrayList<T>> loadMetaData() {
		 System.out.println("Inside loadmetadata method in UtilityMetaDataLoader class");
		List<String> dimensionListNames = dimensionMetaDataLoader.creatingDimensionList();
		HashMap<String, ArrayList<T>> totalHierarchialMapData = dimensionMetaDataLoader
				.loadDimnMetaData(dimensionListNames);

		Iterator<Entry<String, ArrayList<T>>> itr = totalHierarchialMapData.entrySet().iterator();
		// System.out.println("printing the map values");
		while (itr.hasNext()) {
			@SuppressWarnings("rawtypes")
			Map.Entry mEntry = (Map.Entry) itr.next();
			System.out.println("HIERARCHY-META-DATA: " + mEntry.getKey() + " : "
					+ mEntry.getValue());
		}
		return totalHierarchialMapData;
	}
}
